package com.ruoyi.bussiness.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.SftReputationAssessment;
import com.ruoyi.bussiness.service.ISftReputationAssessmentService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信誉考核Controller
 * 
 * @author ruoyi
 * @date 2023-11-12
 */
@Controller
@RequestMapping("/bussiness/assessment")
public class SftReputationAssessmentController extends BaseController
{
    private String prefix = "bussiness/assessment";

    @Autowired
    private ISftReputationAssessmentService sftReputationAssessmentService;

    @RequiresPermissions("bussiness:assessment:view")
    @GetMapping()
    public String assessment()
    {
        return prefix + "/assessment";
    }

    /**
     * 查询信誉考核列表
     */
    @RequiresPermissions("bussiness:assessment:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SftReputationAssessment sftReputationAssessment)
    {
        startPage();
        List<SftReputationAssessment> list = sftReputationAssessmentService.selectSftReputationAssessmentList(sftReputationAssessment);
        return getDataTable(list);
    }

    /**
     * 导出信誉考核列表
     */
    @RequiresPermissions("bussiness:assessment:export")
    @Log(title = "信誉考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SftReputationAssessment sftReputationAssessment)
    {
        List<SftReputationAssessment> list = sftReputationAssessmentService.selectSftReputationAssessmentList(sftReputationAssessment);
        ExcelUtil<SftReputationAssessment> util = new ExcelUtil<SftReputationAssessment>(SftReputationAssessment.class);
        return util.exportExcel(list, "信誉考核数据");
    }

    /**
     * 新增信誉考核
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存信誉考核
     */
    @RequiresPermissions("bussiness:assessment:add")
    @Log(title = "信誉考核", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SftReputationAssessment sftReputationAssessment)
    {
        return toAjax(sftReputationAssessmentService.insertSftReputationAssessment(sftReputationAssessment));
    }

    /**
     * 修改信誉考核
     */
    @RequiresPermissions("bussiness:assessment:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SftReputationAssessment sftReputationAssessment = sftReputationAssessmentService.selectSftReputationAssessmentById(id);
        mmap.put("sftReputationAssessment", sftReputationAssessment);
        return prefix + "/edit";
    }

    /**
     * 修改保存信誉考核
     */
    @RequiresPermissions("bussiness:assessment:edit")
    @Log(title = "信誉考核", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SftReputationAssessment sftReputationAssessment)
    {
        return toAjax(sftReputationAssessmentService.updateSftReputationAssessment(sftReputationAssessment));
    }

    /**
     * 删除信誉考核
     */
    @RequiresPermissions("bussiness:assessment:remove")
    @Log(title = "信誉考核", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sftReputationAssessmentService.deleteSftReputationAssessmentByIds(ids));
    }
}
